package com.crm.exception;

/**
 * Class Description
 *   try {
	    	String sMailid = request.getParameter("mailid") ;
	    	Long mailid = Long.valueOf(sMailid) ;
	    	
	    	Mail mail = mailService.getMailFromID(mailid,new String[]{ConstantNames.INIT_MAILDAO_MAILCONTENT,ConstantNames.INIT_MAILDAO_MAILLINK,ConstantNames.INIT_MAILDAO_MAILSTATUS,ConstantNames.INIT_MAILDAO_MAILTYPE}) ;
	    	if(mail == null){
	    		ActionMessages errors = new ActionErrors() ;
	    		errors.add("mail",new ActionMessage("mail.mailmanagelist.error.mail.null")) ;
	    		this.saveErrors(request,errors) ;
	    		return mapping.getInputForward() ;
	    	}
			mailService.copyMail(mail) ;
		} catch (DBException e) {
			ThrowGlobalActionException.getInstance().throwBusinessException(e) ;
		}  catch (Exception e){
			ThrowGlobalActionException.getInstance().throwOtherException(e) ;
		}
 * <pre>
 *   Filename        : ConstantExceptionKeys.java 
 *   Date			   : 2008-08-18
 *   Creator         : liuqing
 *   Revised Description 
 *   ----------------------------------------------
 *   ver	revised date	reviser	revised contents
 *   0.1   2008-08-18       liuqing            create
 *   ----------------------------------------------
 *   
 * </pre>
 */
public class ThrowGlobalActionException {

	private volatile static ThrowGlobalActionException uniqueIntance;

	private ThrowGlobalActionException() {

	}
	
	public static ThrowGlobalActionException getInstance(){
		if(uniqueIntance==null){
			synchronized(ThrowGlobalActionException.class){
				uniqueIntance=new ThrowGlobalActionException();
			}
		}
		return uniqueIntance;
	}
	
	/**
	 * Creator      : liuqing
	 * Description: 抛出BusinessException体系
	 * @param    	BusinessException e
	 * @return   	
	 *@throws       BusinessException
	 * ----------------------------------------------
	 * ver	revised date reviser	revised contents
	 * 1.0  2008-08-12   liuqing    created this method
	 * ----------------------------------------------
	 *
	 */
	public  void throwBusinessException(BusinessException e) throws BusinessException
	{
		if(e instanceof DBException){
			throw new DBException(e.getMessage()) ;
		}else if(e instanceof ServiceException){
			throw new ServiceException(e.getMessage()) ;
		}else if(e instanceof ConvertException){
			throw new ConvertException(e.getMessage()) ;
		}else if(e instanceof BusinessException){
			throw new BusinessException(e.getMessage()) ;
		}else{
			throw new BusinessException(e.getMessage()) ;
		}
		//add other gloabl exception.
	}
	
	/**
	 * Creator      : liuqing
	 * Description: 抛出BusinessException体系中其它的exception
	 * @param    	BusinessException e
	 * @return   	
	 *@throws       BusinessException
	 * ----------------------------------------------
	 * ver	revised date reviser	revised contents
	 * 1.0  2008-08-12   liuqing    created this method
	 * ----------------------------------------------
	 *
	 */
	public  void throwOtherException()throws BusinessException{
		throw new BusinessException(ConstantExceptionKeys.EXCEPTION_GLOABLE_BUSINESS_OTHER) ;
	}
}
